package org.example.javase.copy;

public class DeepCloneTest implements Cloneable {

    private int age;
    private DeepExperience deepExperience;

    public DeepCloneTest() {
        this.age = 10;
        this.deepExperience = new DeepExperience();
    }

    public DeepExperience getExperience() {
        return deepExperience;
    }

    public void setDeepExperience(String skill) {
        deepExperience.setDeepExperience(skill);
    }

    public void show() {
        System.out.println(deepExperience.toString());
    }

    public int getAge() {
        return age;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        DeepCloneTest deepCloneTest = (DeepCloneTest) super.clone();
        deepCloneTest.deepExperience = (DeepExperience) deepCloneTest.getExperience().clone();
        return deepCloneTest;
    }
}